package main

import "fmt"

func main() {
	// 示例 1。
	s1 := make([]int, 5)
	fmt.Printf("The length of s1: %d\n", len(s1))
	fmt.Printf("The capacity of s1: %d\n", cap(s1))
	fmt.Printf("The value of s1: %d\n", s1)
	
    s2 := make([]int, 5, 8)
	fmt.Printf("The length of s2: %d\n", len(s2))
	fmt.Printf("The capacity of s2: %d\n", cap(s2))
	fmt.Printf("The value of s2: %d\n", s2)

    s3 := []int{1, 2, 3, 4, 5, 6, 7, 8}
    fmt.Printf("The length of s3: %d\n", len(s3))
	fmt.Printf("The capacity of s3: %d\n", cap(s3))
	fmt.Printf("The value of s3: %d\n", s3)
	s4 := s3[3:6]
    fmt.Printf("The length of s4: %d\n", len(s4))
    fmt.Printf("The capacity of s4: %d\n", cap(s4))
    fmt.Printf("The value of s4: %d\n", s4)
    // 容量向右扩展，一直到复制数组的cap
    s5 := []int{1,2,3,4,5,6,7,8,9,10,11,12,13}
    fmt.Printf("The length of s5: %d\n", len(s5))
	fmt.Printf("The capacity of s5: %d\n", cap(s5))
	fmt.Printf("The value of s5: %d\n", s5)
    s6 := s5[3:6]
    fmt.Printf("The length of s6: %d\n", len(s6))
	fmt.Printf("The capacity of s6: %d\n", cap(s6))
	fmt.Printf("The value of s6: %d\n", s6)
    
    fmt.Println()
    arr :=[]int{0,1,2,3,4,5,6,7,8}
    fmt.Println("arr[:]:", arr[:])
    fmt.Println("arr[3:5]:", arr[3:5])

//     fmt.Println("Reslice:arr = arr[:3]")
//     arr = arr[:3]
//     fmt.Println("arr[:3]:", arr[:])

    s1 = arr[2:6]
    fmt.Println("arr[2:6]:", s1)
    fmt.Println("向前扩展不可以，但是可以向后扩展")
    s2 = s1[3:5]
    fmt.Println("arr[3:5]:", s2)
}
